package com.game.doudizhu.controller;

import com.game.doudizhu.model.ShopItem;
import com.game.doudizhu.model.PlayerItem;
import com.game.doudizhu.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/shop")
public class ShopController {
    
    @Autowired
    private ShopService shopService;
    
    @GetMapping("/items")
    public List<ShopItem> getAvailableItems(@RequestParam Long playerId) {
        return shopService.getAvailableItems(playerId);
    }
    
    @GetMapping("/player/{playerId}/items")
    public List<PlayerItem> getPlayerItems(@PathVariable Long playerId) {
        return shopService.getPlayerItems(playerId);
    }
    
    @PostMapping("/purchase/{itemId}")
    public PlayerItem purchaseItem(@PathVariable Long itemId, @RequestParam Long playerId) {
        return shopService.purchaseItem(playerId, itemId);
    }
    
    @PostMapping("/toggle-equip/{itemId}")
    public PlayerItem toggleEquip(@PathVariable Long itemId, @RequestParam Long playerId) {
        return shopService.toggleEquip(playerId, itemId);
    }
} 